<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Config_model extends CI_Model {

    function __construct()
    {
        // Call the Model constructor
        parent::__construct();
    }
    public function get_category_name($category_id)
    {
        $result = $this->db->where('category_id',$category_id)->get('categories');
        return $result;  
    }
    public function get_subcategory_name($subcategory_id)
    {
        $result = $this->db->where('subcategories_id',$subcategory_id)->get('subcategories');
        return $result;  
    }    
    public function get_categories()
    {
        $result = $this->db->get('categories');
        return $result;  
    }
    public function get_subcategories($category_id)
    {
        $result = $this->db->where('category_id',$category_id)->get('subcategories');
        return $result;        
    }

    public function get_all_brands()
    {
        $result = $this->db->get('brands');
        return $result;
    }
    public function get_brands()
    {
        $result = $this->db->get('brands');
        return $result;
    }
    public function get_brand_name($brand_id)
    {
        $result = $this->db->where('brand_id',$brand_id)->get('brands');
        return $result;
        
    }
    public function get_brands_by_category_and_subcategory($category_id,$subcategory_id)
    {
        $this->db->select('brand_id');
        $this->db->distinct('brand_id');
        $result = $this->db->where(array('category_id' => $category_id , 'subcategory_id' => $subcategory_id ))->get('products');
        
        return $result;        
    }
    public function get_brand_products_by_category_and_subcategort($brand_id,$category_id,$subcategory_id)
    {

            $result = $this->db->where(array('brand_id' => $brand_id , 'category_id' => $category_id , 'subcategory_id' => $subcategory_id ))->get('products');
            return $result;
        

    }
    public function get_products($category_id,$subcategory_id,$brand_id)
    {
        $result = $this->db->where(array('category_id' => $category_id, 'subcategory_id' =>$subcategory_id,'brand_id' => $brand_id))->get('products');
        return $result;        
    }
    public function list_categories($category_id, $subcategory_id)
    {
        $result = $this->db->where(array('category_id' => $category_id, 'subcategory_id' => $subcategory_id))->get('brands');
        return $result;
    }
    


}
?>